package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
    /**
     * 添加购物车
     * @param shoppingCart
     */
    void addShoppingCar(@Param("shoppingCart") ShoppingCart shoppingCart );

    /**
     * 查询是否有这一个订单
     * @param userId
     * @param shoppingCartDTO
     * @return
     */
    ShoppingCart findNum(@Param("userId") Long userId,@Param("shoppingCartDTO") ShoppingCartDTO shoppingCartDTO);

    /**
     * 更新数量
     * @param shoppingCart
     */
    void upNumberaddShoppingCar(@Param("shoppingCart") ShoppingCart shoppingCart);

    /**
     * 查看购物车
     * @param userId
     * @return
     */
    List<ShoppingCart> ViewShoppingCar(@Param("userId") Long userId);

    /**
     * //购物车数量-1
     * @param shoppingCartDTO
     * @param userId
     */
    void UsbShoppingCar(@Param("shoppingCartDTO") ShoppingCartDTO shoppingCartDTO,@Param("userId") Long userId );

    /**
     * 删除购物车中一个商品
     * @param userId
     */
    void delNum0ShoppingCar(@Param("userId") Long userId);

    /**
     * 清空购物车
     * @param userId
     */
    void DeleteShoppingCar(@Param("userId") Long userId);

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> findCartListByUserId(Long userId);
}
